import os
import re
import time
import sys
from threading import Thread
from modules.graphic import twittheader
import twittconsts

class hometimer(Thread):

	def __init__ (self,h):
		Thread.__init__(self)
		self.h = h
		self.cont=False
		self.iscompute=False
		self.active=True

	def run(self):
			while self.cont:
		
				self.iscompute=True
				twittheader.getHeader()
		
				self.h.load()
				self.h.show()
				print "\nPress any key to stop"
				self.iscompute=False
				time.sleep(twittconsts.TIME_REF)

	def activate(self):
		self.cont=True


	def stop(self):
		self.cont=False

		while self.iscompute:
			continue
		twittheader.getHeader()

	def release(self):
		self.active=False

	
